<template>
  <div class="container">
    <h3>数据交互</h3>

    <h4>同域资源</h4>
    <div>{{title}}</div>

    <h4>跨域资源</h4>
    <div>{{data}}</div>
  </div>
</template>

<script>

export default {

  async asyncData({$axios}){
    let res = await $axios({url:'/data/list.json'})
    // console.log('读取到的静态资源',res.data)
    
    //读取跨域数据
    let res2 = await $axios({url:'/api/goods/home',params:{_limit:1}})
    // console.log('读取到的跨域资源',res2.data)

    return {
      title:res.data.title,
      data:res2.data.data
    }
  },

  async fetch({$axios}){
    // let res = await $axios({url:'/data/list.json'})
    // console.log('res',res.data.title)
  },
  
  components: {
  },
  
}
</script>

<style>

</style>
